/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * VerProfessores.java
 *
 * Created on 14/11/2012, 15:05:46
 */
package distribuicaoDeProfessores;

/**
 *
 * @author Jaime
 */
public class VerProfessores extends javax.swing.JPanel {

    /** Creates new form VerProfessores */
    public VerProfessores(Professores professores) {
       
        initComponents();
        atualizar(professores);
    }

   /* public void remover(){
        for(int i = 0; i < modeloProfessor.getRowCount(); i++)
            modeloProfessor.removeRow(0);
    }*/
    
    public void atualizar(Professores professores){
        javax.swing.table.DefaultTableModel modeloProfessor;
        String nomes[] = new String[5];
        modeloProfessor = new javax.swing.table.DefaultTableModel();
        modeloProfessor.addColumn("Código");
        modeloProfessor.addColumn("Nome");
        modeloProfessor.addColumn("Preferencia 1");
        modeloProfessor.addColumn("Preferencia 2");
        modeloProfessor.addColumn("Preferencia 3");
        java.text.DecimalFormat format = new java.text.DecimalFormat("000000");
        //for(int i = 0; i < professores.getProfessores().size(); i++)
         //   remover();
        
        for(int i = 0; i < professores.getProfessores().size(); i++){
            nomes[0]= format.format(i);
            nomes[1]= professores.getProfessores().get(i).getNome();
            nomes[2]= ""+professores.getProfessores().get(i).getP1();
            nomes[3]= ""+professores.getProfessores().get(i).getP2();
            nomes[4]= ""+professores.getProfessores().get(i).getP3();
          
            modeloProfessor.addRow(nomes);
        }
        tabela.setModel(modeloProfessor);
        
        
    this.repaint();
    }   
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tabela = new javax.swing.JTable();

        setBackground(new java.awt.Color(102, 255, 102));
        setLayout(new java.awt.BorderLayout());

        jLabel1.setBackground(new java.awt.Color(153, 255, 153));
        jLabel1.setFont(new java.awt.Font("Script MT Bold", 0, 48));
        jLabel1.setForeground(new java.awt.Color(255, 51, 51));
        jLabel1.setText("Ver todos os Professores");
        add(jLabel1, java.awt.BorderLayout.PAGE_START);

        tabela.setBackground(new java.awt.Color(220, 253, 220));
        tabela.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null}
            },
            new String [] {
                "Código", "Nome", "Preferencia 1", "Preferencia 2", "Preferencia 3", "Diciplinas Alocadas"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tabela.setFocusable(false);
        tabela.setGridColor(new java.awt.Color(255, 51, 51));
        jScrollPane1.setViewportView(tabela);
        tabela.getColumnModel().getColumn(0).setResizable(false);
        tabela.getColumnModel().getColumn(1).setResizable(false);
        tabela.getColumnModel().getColumn(2).setResizable(false);
        tabela.getColumnModel().getColumn(3).setResizable(false);
        tabela.getColumnModel().getColumn(4).setResizable(false);
        tabela.getColumnModel().getColumn(5).setResizable(false);

        add(jScrollPane1, java.awt.BorderLayout.CENTER);
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable tabela;
    // End of variables declaration//GEN-END:variables
    
}
